﻿using DevExpress.ExpressApp.DC;
using System.Reflection;

namespace EasyXaf.EntityDesigner.ModelBuilders;

public class ModelBuilder
{
    public EntityTypeBuilder<TEntity> Entity<TEntity>(ITypeInfo typeInfo)
    {
        return new EntityTypeBuilder<TEntity>(typeInfo);
    }

    public IEntityTypeBuilder Entity(Type entityType, ITypeInfo typeInfo)
    {
        var entityMethod = GetType().GetMethod(nameof(Entity), BindingFlags.Public | BindingFlags.Instance, [typeof(ITypeInfo)]);
        return entityMethod.MakeGenericMethod(entityType).Invoke(this, [typeInfo]) as IEntityTypeBuilder;
    }
}
